import React, { Component } from 'react'
import Search from '../Search/Search'
import styles from './Seek.module.scss'
import {getEverybody} from '../../data/api'
import {withRouter} from 'react-router-dom'

class Seek extends Component {
  state = {
    Everybody:[]
  }

  async componentDidMount() {
    let Everybody = await getEverybody()
    this.setState({
      Everybody:Everybody.data
    })
  }
  componentWillUnmount() {
    this.setState = () => false;
}
handleClick=(id) => {
  this.props.history.push('detailed/'+id)
}

  render() {
    return (
      <div>
        <Search disabled={false} right={true}></Search>
        <div className={styles.seek_center}>
          <div className={styles.title}>热门搜索</div>
          <div className={styles.item}>
            {this.state.Everybody.map((v) => {
              return <p key={v.bookId} onClick={this.handleClick.bind(this,v.bookId)}> {v.bookName} </p>
            })}
          </div>
        </div>
      </div>
    )
  }
}
export default withRouter(Seek);
